﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
using System.Globalization;

namespace weighing
{
   public class MaterialCurrSalePriceConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (App.CurrentUser.roleType == (int)UserRoleType.Weighinger)
            {
                return "无权查看";
            }
            if (value == null)
            {
                return "￥ 0.00 元/吨";
            }
            var salePrice = MaterialPriceDao.Instance.GetMaterialCurrPrice(System.Convert.ToInt64(value), MaterialPriceType.Sale);
            if (salePrice != null)
            {
                return $"￥ { salePrice.price} 元/吨";
            }
            return "￥ 0.00 元/吨";
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
